package com.example.flshtarvel.service;

import com.example.flshtarvel.entity.Image;
import com.example.flshtarvel.mapper.ImageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service
public class ImageService {
    @Autowired(required = false)
    ImageMapper imageMapper;

    public int insertImage(Image image){
        image.setImageId(UUID.randomUUID().toString());
        return imageMapper.insertImage(image);
    }

    //根据信息id查询图片 返回List<Image>
    public List<Image> selectImageById(String articleId){
        return imageMapper.selectImageByArticleId(articleId);
    }

//    //根据信息id查询图片 返回urls（路径字符串，以“；”拼接）
//    public List<Image> selectImageUrlsById(String articleId){
//        return imageMapper.selectImageByArticleId(articleId);
//    }

    public int deleteImage(String imageId){
        return imageMapper.deleteImage(imageId);
    }
}
